#include	"DataRep.hpp"

using namespace std;
_BOF_ZIA_API_

DataRep::DataRep()
{
}
DataRep::~DataRep()
{
}
bool											DataRep::hasValue(const std::string& key) const
{
	bool										ret = false;

	if (this->mValues.find(key) != this->mValues.end())
		ret = true;
	return (ret);
}

bool											DataRep::hasList(const std::string& key) const
{
	bool										ret = false;

	if (this->mLists.find(key) != this->mLists.end())
		ret = true;
}

void											DataRep::value(const std::string& key, 
												const std::string& value)
{
	this->mValues[key] = value;
	return ;
}

const std::string&								DataRep::value(const std::string& key) const
{
	static	std::string							ret = "";

	if  (this->hasValue(key) == 1)
		return (this->mValues.find(key)->second);
	else
		return (ret);
}

std::list< std::string >&						DataRep::list(const std::string& key)
{
	return (this->mLists[key]);
}

const std::list< std::string >&					DataRep::const_list(const std::string& key) const
{
	return (this->mLists.find(key)->second);
}

void											DataRep::clear()
{
	this->mLists.clear();
	this->mValues.clear();
	return ;
}

void											DataRep::print(std::ostream& out) const
{
	map<string, string>::const_iterator	vIt = this->mValues.begin(), \
												vIte = this->mValues.end();
	map<string, std::list<string> >::const_iterator	lIt = this->mLists.begin(), \
													lIte = this->mLists.end();
	
	while (vIt != vIte)
	{
		cout << "Key: '" << vIt->first << "' Value: '" << vIt->second << "'" << endl;
		++vIt;
	}
	while (lIt != lIte)
	{
		cout << "Key: '" << lIt->first << "'" << endl;
		cout << "Value(s): " << endl;
		std::list<string>::const_iterator it = lIt->second.begin(), ite = lIt->second.end();

		while (it != ite)
		{
			cout << "\t - " << (*it) << endl;
			++it;
		}
		++lIt;
	}
}

const std::map< std::string, std::string >&		DataRep::getValues() const
{
	return (this->mValues);
}

const std::map< std::string, std::list< std::string > >&	DataRep::getLists() const
{
	return (this->mLists);
}

_EOF_ZIA_API_
